//////////////////////////////////////////////////////////////////////
//
//	Copyright 2010-2011 Rogo's Team. All Rights Reserved
//
//////////////////////////////////////////////////////////////////////
package com.rogo.util
{
	import flash.display.NativeWindow;
	import flash.display.Screen;

	/**
	 * 桌面辅助类
	 * 
	 * @author rogo
	 */	
	public class DesktopUtil
	{
		public function DesktopUtil()
		{
		}
		
		//--------------------------------------------------------------------------
		//
		//  Static Methods
		//
		//--------------------------------------------------------------------------
		
		/**
		 *	将 本地窗口 移至屏幕中央
		 * 
		 * @param nativeWindow 本地窗口
		 */		
		public static function moveToCenter(nativeWindow:NativeWindow):void
		{
			var sx:Number = (screenWidth - nativeWindow.width) / 2;
			var sy:Number = (screenHeight - nativeWindow.height) / 2;
			
			nativeWindow.x = sx + screenX;
			nativeWindow.y = sy + screenY;
		}
		
		/**
		 * 设置窗口大小
		 * 
		 * @param nativeWindow
		 * @param width
		 * @param height
		 */		
	 	public static function setSize(nativeWindow:NativeWindow, width:Number, height:Number):void
		{
			width = width > screenWidth ? screenWidth : width;
			height = height >screenHeight ? screenHeight : height;
			nativeWindow.width = width;
			nativeWindow.height = height;
		}
		
	 	public static function get screenWidth():Number
		{
			return Screen.mainScreen.visibleBounds.width;
		}
		
		public static function get screenHeight():Number
		{
			return Screen.mainScreen.visibleBounds.height;
		}
		
		public static function get screenX():Number
		{
			return Screen.mainScreen.visibleBounds.x;
		}
		
		public static function get screenY():Number
		{
			return Screen.mainScreen.visibleBounds.y;
		}
	}
}